package io.github.talelin.latticy.model;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Map;

/**
 * 积分记录实体
 * @author talelin
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("points_record")
@EqualsAndHashCode(callSuper = true)
public class PointsRecordDO extends BaseModel implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 用户ID
     */
    @TableField("user_id")
    private Long userId;

    /**
     * 积分变动类型：earned(获得), used(使用), expired(过期), adjusted(调整)
     */
    @TableField("type")
    private String type;

    /**
     * 积分数量
     */
    @TableField("points")
    private Integer points;

    /**
     * 积分标题
     */
    @TableField("title")
    private String title;

    /**
     * 积分描述
     */
    @TableField("description")
    private String description;

    /**
     * 积分来源/用途：purchase(购买), signin(签到), activity(活动), exchange(兑换), admin(管理员调整)等
     */
    @TableField("source")
    private String source;

    /**
     * 关联订单ID
     */
    @TableField("order_id")
    private Long orderId;

    /**
     * 状态：success(成功), pending(处理中), failed(失败), expired(已过期)
     */
    @TableField("status")
    private String status;

    /**
     * 过期时间
     */
    @TableField("expire_date")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime expireDate;

    /**
     * 额外信息（JSON格式）
     */
    @TableField("extra")
    private String extra;

    /**
     * 变动前积分余额
     */
    @TableField("balance_before")
    private Integer balanceBefore;

    /**
     * 变动后积分余额
     */
    @TableField("balance_after")
    private Integer balanceAfter;
}
